<template>
  <el-input @input="handleInput" v-model="iptVal"></el-input>
  <span>{{ spanText }}</span>
  <el-button type="primary" @click="handleClick">测试节流</el-button>
  <el-button type="primary" v-throttle="testThrottle">测试节流指令</el-button>
</template>
<script setup lang="ts">
import { debounce, throttle } from 'lodash-es'
import { ref } from 'vue'
const iptVal = ref('')
const spanText = ref('')
const handleInput = debounce(
  (e: string) => {
    spanText.value = e
  }, 300
)
const handleClick = throttle(() => {
  console.log('点击了')
}, 2000)

function testThrottle() {
  console.log('点击节流指令')
}
</script>
